//
//  VipTableViewCell.m
//  markmap
//
//  Created by 甘世清 on 2024/6/21.
//

#import "VipTableViewCell.h"

@implementation VipTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)SQ_Style:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    UIView * bgView= [[UIView alloc]init];
    bgView.backgroundColor = SQColor(@"#6B6B6B");
    bgView.layer.cornerRadius = 12;
    bgView.layer.masksToBounds  = YES;
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(6, 16, 6, 16));
    }];
    self.bgimage = [[UIImageView alloc]init];
    self. bgimage.image = SQGetImage(@"midoubg");
    [self.contentView addSubview:self.bgimage];
    [self.bgimage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(6, 16, 6, 16));
    }];
    [self.contentView addSubview:self.midouLabel];
    [self.midouLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(bgView);
            make.left.equalTo(bgView).offset(26);
    }];
    [self.contentView addSubview:self.moneyLabel];
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(bgView).offset(-15);
            make.right.equalTo(bgView.mas_right).offset(-20);
    }];
    [self.contentView addSubview:self.numberLabel];
    [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(bgView).offset(15);
            make.right.equalTo(bgView.mas_right).offset(-16);
        make.height.mas_equalTo(22);
        make.width.mas_equalTo(120);
    }];
    
}
- (void)setModel:(MiDouModel *)model{
    _model = model;
    if (model.isseleted) {
        self.bgimage.hidden = NO;
        _moneyLabel.textColor = UIColor.whiteColor;
        _numberLabel.textColor = UIColor.whiteColor;
        _numberLabel.backgroundColor = SQColor(@"#000000");
        _midouLabel.textColor = UIColor.whiteColor;
    } else {
        self.bgimage.hidden = YES;
        _moneyLabel.textColor = SQColor333333;
        _numberLabel.textColor = SQColor333333;
        _numberLabel.backgroundColor = SQColor(@"#8F8F8F");
        _midouLabel.textColor = SQColor333333;
    }
    self.midouLabel.text = model.name;
    self.moneyLabel.text = [NSString stringWithFormat:@"%@%@",model.prefix,model.price];
    self.numberLabel.text = [NSString stringWithFormat:@"%@%@ %@%d",SQNSLocalString(@"原价"),model.orgPrice,SQNSLocalString(@"立省"),[model.orgPrice intValue]-[model.price intValue]];
}


- (UILabel *)midouLabel{
    if (!_midouLabel) {
        _midouLabel = [[UILabel alloc]init];
        _midouLabel.textColor = UIColor.whiteColor;
        _midouLabel.font = FONT_MEDIUM(16);
    }
    return _midouLabel;
}
- (UILabel *)moneyLabel{
    if (!_moneyLabel) {
        _moneyLabel = [[UILabel alloc]init];
        _moneyLabel.textColor = UIColor.whiteColor;
        _moneyLabel.font = FONT_MEDIUM(22);
    }
    return _moneyLabel;
}
- (UILabel *)numberLabel{
    if (!_numberLabel) {
        _numberLabel = [[UILabel alloc]init];
        _numberLabel.textColor = UIColor.whiteColor;
        _numberLabel.font = FONT_REGULAR(12);
        _numberLabel.layer.cornerRadius = 6;
        _numberLabel.layer.masksToBounds = YES;
        _numberLabel.textAlignment = NSTextAlignmentCenter;
        _numberLabel.backgroundColor = SQColor(@"#000000");
    }
    return _numberLabel;
}

@end
